import java.util.Random;

public abstract class Deposit implements IBTMSetting {
	
	protected int block;
	protected byte metadata;
	protected DepositValues[] deposits;
	protected int xyPos;
	public static Random rand;
	public static et world;
	protected int _x;
	protected int _y;
	protected int _z;
	protected int currDep;
	protected int freq;
	protected boolean doit;
	protected int defaultX;
	protected int defaultY;
	protected int defaultZ;
	protected int defaultMinX;
	protected int defaultMinY;
	protected int defaultMinZ;
	public void process(int x,int z) 
	{
		
			for(int j=0;j<freq;j++)
			{	
				 if (rand.nextInt(100) < deposits[currDep].getRarity()) {
					 doit=true;
				        _x = x + rand.nextInt(16) + xyPos;
				        _z = z + rand.nextInt(16) + xyPos;
				        _y = rand.nextInt(deposits[currDep].getMaxAltitude() - deposits[currDep].getMaxAltitude()) + deposits[currDep].getMaxAltitude();
				 }
				 else
					 doit=false;
			}
		
		
	}
	@Override
	public void fetchSettings(AltLoader al) {};
	@Override
	public void writeSettings(java.io.BufferedOutputStream bof) {};
	public Deposit(byte type,byte meta,int size,int xy)
	{
		xyPos=xy;
		deposits=new DepositValues[size];
		block=type;
		metadata=meta;
		currDep=0;
	}
	public void defaultProcess(int x,int z) {
		_x=x+rand.nextInt(defaultX)+defaultMinX;
		_y=rand.nextInt(defaultY)+defaultMinY;
		_z=z+rand.nextInt(defaultZ)+defaultMinZ;
		
		
	}
	public static void init(et _world,long seed)
	{
		world=_world;
		rand=new Random();
		rand.setSeed(seed);
		
	}
	public void initDefault(int minx,int miny,int minz,int defx,int defy,int defz)
	{
		defaultX=defx;
		defaultY=defy;
		defaultZ=defz;
		defaultMinX=minx;
		defaultMinY=miny;
		defaultMinZ=minz;
	}
	
}
